/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.objects;

/**
 * SISession object
 * @author Kyle Parker, University Computing Services
 */
public class SISession implements Comparable<SISession> {
	private String beginTime;
	private String buildingCode;
	private String buildingDesc;
	private String day;
	private String endTime;
	private String locationID;
	private String room;
    
	public String getBeginTime() {		
		return beginTime;
	}
	public void setBeginTime(String value)  {
		this.beginTime = value.trim();
	}

	public String getBuildingCode() {		
		return buildingCode;
	}
	public void setBuildingCode(String value) {
		this.buildingCode = value.trim();
	}

	public String getBuildingDesc() {		
		return buildingDesc;
	}
	public void setBuildingDesc(String value) {
		this.buildingDesc = value.trim();
	}

	public String getDay() {		
		return day;
	}
	public void setDay(String value) {
		this.day = value.trim();
	}

	public String getEndTime() {		
		return endTime;
	}
	public void setEndTime(String value) {
		this.endTime = value.trim();
	}

	public String getLocationID() {		
		return locationID;
	}
	public void setLocationID(String value) {
		this.locationID = value.trim();
	}

	public String getRoom() {		
		return room;
	}
	public void setRoom(String value) {
		this.room = value.trim();
	}
	
	public SISession copy() {
		SISession copy = new SISession();
		copy.beginTime = beginTime;
		copy.buildingCode = buildingCode;
		copy.buildingDesc = buildingDesc;
		copy.day = day;
		copy.endTime = endTime;
		copy.locationID = locationID;
		copy.room = room;
		return copy;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((beginTime == null) ? 0 : beginTime.hashCode());
		result = prime * result + ((buildingCode == null) ? 0 : buildingCode.hashCode());
		result = prime * result + ((buildingDesc == null) ? 0 : buildingDesc.hashCode());
		result = prime * result + ((day == null) ? 0 : day.hashCode());
		result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
		result = prime * result + ((locationID == null) ? 0 : locationID.hashCode());
		result = prime * result + ((room == null) ? 0 : room.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) { return true; }
		
		if (obj == null) { return false; }
		
		if (getClass() != obj.getClass()) { return false; }
		
		SISession other = (SISession) obj;
		
		if (beginTime == null)  {
			if (other.beginTime != null) { return false; }
		} else if (!beginTime.equals(other.beginTime)) { return false; }
		
		if (buildingCode == null) {
			if (other.buildingCode != null) { return false; }
		} else if (!buildingCode.equals(other.buildingCode)) { return false; }
		
		if (buildingDesc == null)  {
			if (other.buildingDesc != null) { return false; }
		} else if (!buildingDesc.equals(other.buildingDesc)) { return false; }
		
		if (day == null) {
			if (other.day != null) { return false; }
		} else if (!day.equals(other.day)) { return false; }
		
		if (endTime == null)  {
			if (other.endTime != null) { return false; }
		}  else if (!endTime.equals(other.endTime)) { return false; }
		
		if (locationID == null) {
			if (other.locationID != null) { return false; }
		} else if (!locationID.equals(other.locationID)) { return false; }
		
		if (room == null) {
			if (other.room != null) { return false; }
		}  else if (!room.equals(other.room)) { return false; }
		
		return true;
	}

	public int compareTo(SISession another) {
		if (another == null) return 1;
		// sort descending, most recent first
		return another.locationID.compareTo(locationID);
	}
}
